home *** CD-ROM | disk | FTP | other *** search
- -- Gesture Snap to Sprite
-
-
- property snapDistance, snapTarget, xoffset, yoffset
- property tracking, boxtop, boxleft, boxright,boxbottom
-
- on beginsprite me
- set boxtop = the locv of sprite snapTarget - snapDistance
- set boxbottom = the locv of sprite snapTarget + snapDistance
- set boxleft = the loch of sprite snapTarget - snapDistance
- set boxright = the loch of sprite snapTarget + snapDistance
-
-
- end
-
- on prepareframe me
- if tracking then
- if inbox (me, the mouseH - xoffset, the mouseV - yoffset) then
- snap me
- else
- set the locH of sprite the spritenum of me = the MouseH - xoffset
- set the locV of sprite the spritenum of me = the MouseV - yoffset
- end if
- end if
- end
-
- on mousedown me
- set tracking = TRUE
- set xoffset = the mouseH - the locH of sprite the spritenum of me
- set yoffset = the mouseV - the locV of sprite the spritenum of me
-
- end
-
- on mouseup me
- set tracking = FALSE
- end
-
- on snap me
- set the locH of sprite the spritenum of me = the locH of sprite snapTarget
- set the locV of sprite the spritenum of me = the locV of sprite snapTarget
- end
-
-
- on inbox me,x,y
- if x < boxright and x > boxleft and y < boxbottom and y > boxtop then
- return 1
- end if
- return 0
- end
-
-
- ---
-
- on getPropertyDescriptionList
-
- set p_list = [ ¬
- #snapDistance: [ #comment: "Snap Distance:", ¬
- #format: #integer, ¬
- #default: 8 ], ¬
- #snapTarget: [ #comment: "Target Sprite:", ¬
- #format: #integer, ¬
- #default: 1 ] ¬
- ]
- return p_list
- end
-
- on getBehaviorDescription
- return ¬
- "Cause a sprite to snap to the registration point of the target sprite while being dragged. " & RETURN & ¬
- "PARAMETERS:" & RETURN & ¬
- "• Snap Distance - Enter the range in pixels within which snapping occurs." & RETURN & ¬
- "ΓÇó Snap Target - Enter the channel number of the sprite to snap to."
-
- end